/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import java.sql.*;


/**
 *UPDATE USER SET PASSWORD=PASSWORD('nuevo_pass') WHERE USER='root';
 * @author JAVA
 */
public class PersistenciaConexion {
    //static String host      = "192.168.1.12";
    static String host      = "127.0.0.1";
    static String baseDatos = "thenet";
    static String usuario   = "Aula2pc02";
    static String password  = "Aula2pc02";
    

    
    /**
     * Crea la conexion con la BBDD THENET
     * @throws ClassNotFoundException
     * @throws IllegalAccessException
     * @throws InstantiationException
     * @throws SQLException 
     */
    
    public static Connection crearConexion()
    {
        Connection con = null;
        try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            con = DriverManager.getConnection("jdbc:mysql://"+host+"/"+baseDatos,usuario, password);
            //con = DriverManager.getConnection("jdbc:mysql://localhost/thenet", "root", "admin");
        }
        catch (Exception e){
            System.out.println("Error al intentar abrir la conexion "+e.getMessage());
            //e.printStackTrace();
        }
        return con;
    }

    public static void cerrarConexion(Connection con)
    {
        try{
            con.close();
        }
        catch(SQLException e)
        {
            System.out.println("Error al cerrar la conexion a la base de datos "+e.getMessage());
        }
    }
}